WAIT4(2) | п═я┐п╨п╬п╡п╬п╢я│я┌п╡п╬ п©я─п╬пЁя─п╟п╪п╪п╦я│я┌п╟ Linux | WAIT4(2) |
п≤п°п╞¶
wait3, wait4 - п╬п╤п╦п╢п╟п╣я┌ я│п╪п╣п╫я┐ я│п╬я│я┌п╬я▐п╫п╦я▐ п╡ я│я┌п╦п╩п╣ BSD
п·п▒п≈п·п═¶
#include <sys/types.h> #include <sys/time.h> #include <sys/resource.h> #include <sys/wait.h> pid_t wait3(int *status, int options, struct rusage *rusage); pid_t wait4(pid_t pid, int *status, int options, struct rusage *rusage);
п╒я─п╣п╠п╬п╡п╟п╫п╦я▐
п╪п╟п╨я─п╬я│п╟
я┌п╣я│я┌п╦я─п╬п╡п╟п╫п╦я▐
я│п╡п╬п╧я│я┌п╡
п╢п╩я▐ glibc
(я│п╪. feature_test_macros(7)):
wait3(): _BSD_SOURCE
wait4(): _BSD_SOURCE || _XOPEN_SOURCE >= 500
п·п÷п≤п║п░п²п≤п∙¶
п║п╦я│я┌п╣п╪п╫я▀п╣ п╡я▀п╥п╬п╡я▀ wait3() п╦ wait4() п©п╬я┘п╬п╤п╦ п╫п╟ waitpid(2), п╫п╬ п╢п╬п©п╬п╩п╫п╦я┌п╣п╩я▄п╫п╬ п╡п╬п╥п╡я─п╟я┴п╟я▌я┌ п╦п╫я└п╬я─п╪п╟я├п╦я▌ п╬п╠ п╦я│п©п╬п╩я▄п╥п╬п╡п╟п╫п╦п╦ я─п╣я│я┐я─я│п╬п╡ п©п╬я┌п╬п╪п╨п╬п╪ п╡ я│я┌я─я┐п╨я┌я┐я─п╣, я┐п╨п╟п╥я▀п╡п╟п╣п╪п╬п╧ rusage.
п÷п╬п╪п╦п╪п╬ п╦я│п©п╬п╩я▄п╥п╬п╡п╟п╫п╦я▐ п╟я─пЁя┐п╪п╣п╫я┌п╟ rusage, п╡я▀п╥п╬п╡ wait3():
я█п╨п╡п╦п╡п╟п╩п╣п╫я┌п╣п╫:
wait3(status, options, rusage);
п÷п╬п╢п╬п╠п╫п╬ я█я┌п╬п╪я┐, п╡я▀п╥п╬п╡ wait4():
waitpid(-1, status, options);
я█п╨п╡п╦п╡п╟п╩п╣п╫я┌п╣п╫:
wait4(pid, status, options, rusage);
п■я─я┐пЁп╦п╪п╦ я│п╩п╬п╡п╟п╪п╦, wait3() п╬п╤п╦п╢п╟п╣я┌ п╩я▌п╠п╬пЁп╬ п©п╬я┌п╬п╪п╨п╟, п╟ п╢п╩я▐ wait4() п╪п╬п╤п╣я┌ п╠я▀я┌я▄ я┐п╨п╟п╥п╟п╫ п╬п©я─п╣п╢п╣п╩я▒п╫п╫я▀п╧ п©п╬я┌п╬п╪п╬п╨ п╦п╩п╦ п©п╬я┌п╬п╪п╨п╦, п╨п╬я┌п╬я─я▀я┘ п╫я┐п╤п╫п╬ п╬п╤п╦п╢п╟я┌я▄. п÷п╬п╢я─п╬п╠п╫п╣п╧ я│п╪. wait(2).
waitpid(pid, status, options);
п∙я│п╩п╦ rusage п╫п╣ я─п╟п╡п╫п╬ NULL, я┌п╬ struct rusage, п╫п╟ п╨п╬я┌п╬я─я┐я▌ п╬п╫ я┐п╨п╟п╥я▀п╡п╟п╣я┌, п╠я┐п╢п╣я┌ п╥п╟п©п╬п╩п╫п╣п╫ п╦п╫я└п╬я─п╪п╟я├п╦п╣п╧ п╬ я─п╟п╠п╬я┌п╣ п©п╬я┌п╬п╪п╨п╟. п÷п╬п╢я─п╬п╠п╫п╣п╧ я│п╪. getrusage(2).
п▓п·п≈п▓п═п░п╘п░п∙п°п·п∙ п≈п²п░п╖п∙п²п≤п∙¶
п п╟п╨ п╡ waitpid(2).
п·п╗п≤п▒п п≤¶
п п╟п╨ п╡ waitpid(2).
п║п·п·п╒п▓п∙п╒п║п╒п▓п≤п∙ п║п╒п░п²п■п░п═п╒п░п°¶
4.3BSD.
п≈п░п°п∙п╖п░п²п≤п╞¶
п▓п╨п╩я▌я┤п╟я┌я▄ <sys/time.h> п╡ п╫п╟я│я┌п╬я▐я┴п╣п╣ п╡я─п╣п╪я▐ п╫п╣ я┌я─п╣п╠я┐п╣я┌я│я▐, п╫п╬ я┐п╡п╣п╩п╦я┤п╦п╡п╟п╣я┌ п©п╣я─п╣п╫п╬я│п╦п╪п╬я│я┌я▄. (п▒п╣п╥я┐я│п╩п╬п╡п╫п╬, п╡ <sys/resource.h> п╬п©я─п╣п╢п╣п╩п╣п╫п╟ я│я┌я─я┐п╨я┌я┐я─п╟ rusage я│ п©п╬п╩я▐п╪п╦ я┌п╦п©п╟ struct timeval, п╨п╬я┌п╬я─я▀п╧ п╬п©я─п╣п╢п╣п╩я▒п╫ п╡ <sys/time.h>.)
п▓ Linux, wait3() я▐п╡п╩я▐п╣я┌я│я▐ п╠п╦п╠п╩п╦п╬я┌п╣я┤п╫п╬п╧ я└я┐п╫п╨я├п╦п╣п╧, я─п╣п╟п╩п╦п╥п╬п╡п╟п╫п╫п╬п╧ п╫п╟ п╬я│п╫п╬п╡п╣ я│п╦я│я┌п╣п╪п╫п╬пЁп╬ п╡я▀п╥п╬п╡п╟ wait4().
п║п°п·п╒п═п≤п╒п∙ п╒п░п п√п∙¶
fork(2), getrusage(2), sigaction(2), signal(2), wait(2), signal(7)
2008-09-28 | Linux |